
#ifndef __BUZZER_H
#define __BUZZER_H


#include "gd32f30x.h"
#include <stdbool.h>

#define BUZZER_RCU_GPIOx     RCU_GPIOB
#define BUZZER_GPIOx         GPIOB
#define BUZZER_GPIO_PINx     GPIO_PIN_8

#define BuzzerRingGroup 10

typedef union
{
    struct
    {
				uint32_t pwmdata;
				uint32_t group;
				uint32_t buzzerTime[BuzzerRingGroup];
				uint32_t buzzerSpeed[BuzzerRingGroup];
				uint32_t buzzerMode;
				uint32_t buzzerRingTime;
    } Info;
    uint32_t Byte[(BuzzerRingGroup*2)+4];
} Buzzer_union;

typedef struct
{
	bool enable;
	void (*Ring)(void);
	void (*SetRing)(uint32_t time,uint32_t speed);
}Buzzer_Control;

typedef struct
{
	Buzzer_union config;
	Buzzer_Control control;
}Buzzer_Struct;


void vbuzzerInit(void);
void vbuzzerSetRing(uint32_t time,uint32_t speed);
void vbuzzerRing(void);
void vbuzzerCopyArray_32(uint32_t *sourcearray,uint32_t *targetarray,uint32_t length);

#endif

